package cn.chinaflame.pagodas.repository;

import cn.chinaflame.pagodas.entity.VwAgentAreaItem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author created by lbq
 * @date 2018年1月12日 下午8:47:32
 **/
public interface VwAgentAreaItemRepository extends JpaRepository<VwAgentAreaItem, String>, JpaSpecificationExecutor<VwAgentAreaItem> {

    @Query("select c from VwAgentAreaItem c where c.agentId = ?1")
    public List<VwAgentAreaItem> queryByAgentId(String agentId);

    @Query("select c from VwAgentAreaItem c where c.provinceCode=?1 and c.cityCode is null and c.areaCode is null")
    public List<VwAgentAreaItem> queryByProvinceCode(String provinceCode);

    @Query("select c from VwAgentAreaItem c where c.provinceCode=?1 and c.cityCode=?2 and c.areaCode is null")
    public List<VwAgentAreaItem> queryByProvinceCodeAndCityCode(String provinceCode, String cityCode);

    @Query("select c from VwAgentAreaItem c where c.provinceCode=?1 and c.cityCode=?2 and c.areaCode=?3")
    public List<VwAgentAreaItem> queryByPrCodeAndCiCodeAndArCode(String provinceCode, String cityCode, String areaCode);
}
